package com.ewing.busi.web.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ewing.busi.web.dao.WebBlockVarDao;
import com.ewing.busi.web.model.WebBlockVar;

/**
 * 网站块关联参数
 * 
 * @author tansonlam
 * @createDate 2016年6月2日
 * 
 */
@Repository("webBlockVarService")
public class WebBlockVarService {
    @Resource
    private WebBlockVarDao webBlockVarDao;

    /**
     * 批量获取网页块关联参数
     * 
     * @param webBlockIds
     * @return
     */
    public Map<Integer, List<WebBlockVar>> getBlockVars(Integer[] webBlockIds) {
        Map<Integer, List<WebBlockVar>> groupMap = new HashMap<Integer, List<WebBlockVar>>();
        List<WebBlockVar> blockVarList = webBlockVarDao.getBlockVars(webBlockIds);
        if (blockVarList == null)
            return groupMap;

        for (WebBlockVar webBlockVar : blockVarList) {
            List<WebBlockVar> list = groupMap.get(webBlockVar.getWebBlockId());
            if (list == null) {
                list = new ArrayList<WebBlockVar>();
                groupMap.put(webBlockVar.getWebBlockId(), list);
            }
            list.add(webBlockVar);
        }
        return groupMap;
    }
}
